<%@page isELIgnored="false" pageEncoding="UTF-8" contentType="text/html; UTF-8" %>
    <script type="text/javascript">
        $(function () {
            $('#ssUser').searchbox({
                searcher:function(value,name){
                    $("#tableUser").datagrid("load",{
                        "columnName":name,
                        "columnValue":value,
                    });
                },
                width:300,
                menu:'#mmUser',
                prompt:'请输入值',
            });

            $("#tableUser").datagrid({
                url: "${pageContext.request.contextPath}/back/user/findAll",
                autoRowHeight: true,
                fit:true,
                fitColumns: true,
                toolbar: '#tbUser',
                columns: [[
                    {field: "checkbox", checkbox: true},
                    {title: "头像", field: "photo", width: 100,formatter: function (value, row, index) {
                            return "<img style='width:80px;height:80px;border-radius:50%;display:block;' src='${pageContext.request.contextPath}/"+row.photo+"'/>";
                        }},
                    {title: "手机号", field: "phone", width: 100},
                    {title: "昵称", field: "nickname", width: 100},
                    {title: "等级", field: "level", width: 50},
                    {title: "金币", field: "gold", width: 50},
                    {title: "积分", field: "score", width: 50},
                    {title: "状态", field: "status", width: 50,formatter: function (value, row, index) {
                        if(row.status==0)
                            return "已冻结";
                        else
                            return "正常";
                    }},
                    {
                        title: "操作", field: "options", width: 100, formatter: function (value, row, index) {
                            if(row.status==1)
                                return "<a onclick=updateUserStatus(\""+row.id+"\",0) class='btnUser' data-options=\"iconCls:'icon-cancel',\">冻结用户</a>";
                            else
                                return "<a onclick=updateUserStatus(\""+row.id+"\",1) class='btnUser' data-options=\"iconCls:'icon-ok',\">恢复正常</a>";
                        }
                    }
                ]],
                pagination: true,
                checkOnSelect: true,
                selectOnCheck: true,
                pageList:[5,10,20,40,80,100],
                pageSize:5,
                onLoadSuccess: function () {
                    $(".btnUser").linkbutton();
                }
            });
        });


        //更新供货商信息
        function updateUserStatus(id,status){
            $.ajax({
                type:"POST",
                url:"${pageContext.request.contextPath}/back/user/updateUserStatus",
                data:{"id":id,"status":status},
                success:function(result){
                    $.messager.show({
                        title:'提示信息',
                        msg:result.message,
                        timeout:5000,
                        showType:'slide'
                    });
                    $("#tableUser").datagrid("reload");
                }
            });
        }
    </script>
<table id="tableUser" class="easyui-datagird"></table>

<div id="tbUser">

    <input id="ssUser"></input>
    <div id="mmUser" style="width:120px">
        <div data-options="name:'phone',iconCls:'icon-ok'">手机号</div>
        <div data-options="name:'nickname',iconCls:'icon-ok'">昵称</div>
        <div data-options="name:'level',iconCls:'icon-ok'">等级</div>
        <div data-options="name:'gold',iconCls:'icon-ok'">金币</div>
        <div data-options="name:'score',iconCls:'icon-ok'">积分</div>
        <div data-options="name:'status',iconCls:'icon-ok'">状态（请输入[已冻结(0)|未冻结(1)]）</div>
    </div>
</div>